package com.cincc.cinccimdemo.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.cincc.im.core.IMSipPhoneCtrl;
import com.cincc.im.model.dbmodel.FriendInfo;
import com.cincc.im.model.dbmodel.GroupMemberInfo;
import com.cincc.im.util.ImManager;

import java.util.List;

public class GroupMemberListViewModel extends ViewModel {
    private MutableLiveData<List<GroupMemberInfo>> contactListLiveData;

    public MutableLiveData<List<GroupMemberInfo>> memberListLiveData(String groupId) {
        if (contactListLiveData == null) {
            contactListLiveData = new MutableLiveData<>();
        }
        ImManager.getInstance().getWorkHandler().post(() -> {
            List<GroupMemberInfo> groupMemberInfos = IMSipPhoneCtrl.getInstance().getGroupMemberList(groupId);
            contactListLiveData.postValue(groupMemberInfos);
        });
        return contactListLiveData;
    }
}
